      * cobc -x principal.cbl  gestor_archivo.cbl -o estadisticas.exe
      ******************************************************************
       IDENTIFICATION DIVISION.
      ******************************************************************
       PROGRAM-ID. principal.

      ******************************************************************
       ENVIRONMENT DIVISION.
      ******************************************************************
      ******************************************************************
       DATA DIVISION.
      ******************************************************************
      *****************************************************
       WORKING-STORAGE SECTION.
      *****************************************************

       77 gestor_archivo    PIC X(14) VALUE 'gestor_archivo'.
       01 operacion         PIC X(01).
       01 registro.
         03 COD-CLI         PIC 9(08).
		 03 NRO-SEC         PIC 9(04).
         03 FEC-DESDE       PIC X(10).
         03 FEC-HASTA       PIC X(10).
         03 CATEG-HAB       PIC X(15).
         03 IMPORTE         PIC S9(06)V9(02).
	   01 cliente           PIC 9(08). 
       01 fs-clientes       PIC X(02).
       01 fin               PIC X(01).
	   01 buscar            PIC X(01).
      ******************************************************************
       PROCEDURE DIVISION.
      ******************************************************************
       Begin.
         MOVE 'A' TO Operacion.
         CALL gestor_archivo USING operacion, registro, fs-clientes.
         DISPLAY "File Status Open".
         DISPLAY fs-clientes.

         MOVE 'N' to fin.
         PERFORM until fin='S' or fin='s'
		  DISPLAY "INGRESE 'S' para salir: "
          ACCEPT fin
		  IF fin not = 'S'
            DISPLAY "-------------> Escritura <------------"
            INITIALIZE registro
            DISPLAY "COD-CLI: "
            ACCEPT cod-cli OF registro
            DISPLAY "NRO-SEC: "
            ACCEPT nro-sec OF registro
            DISPLAY "FEC-DESDE: "
            ACCEPT fec-desde OF registro
            DISPLAY "FEC-HASTA: "
            ACCEPT fec-hasta OF registro
            DISPLAY "CATEG-HAB: "
            ACCEPT categ-hab OF registro
            DISPLAY "IMPORTE: "
            ACCEPT importe OF registro
            MOVE 'W' TO Operacion
            CALL gestor_archivo
            USING operacion, registro, fs-clientes
            DISPLAY "File Status WRITE"
            DISPLAY fs-clientes
            DISPLAY '------------'
            DISPLAY "-------------> READ <------------"
            MOVE 'R' TO Operacion
            CALL gestor_archivo USING operacion, registro, fs-clientes
            DISPLAY '  Lectura:'
            DISPLAY COD-CLI   OF registro
            DISPLAY nro-sec   OF registro
            DISPLAY fec-desde OF registro
            DISPLAY fec-hasta OF registro
            DISPLAY CATEG-HAB OF registro
            DISPLAY importe   OF registro
            DISPLAY '------------'
		  END-IF
         END-PERFORM.

		 MOVE 'N' to buscar.
         PERFORM until buscar='S' or buscar='s'
          DISPLAY "--------> Buscar Cliente <----------"
		  DISPLAY "INGRESE 'S' para salir: "
          ACCEPT buscar
		  IF buscar not = 'S'
             INITIALIZE registro
             DISPLAY "COD-CLI: "
             ACCEPT cod-cli OF registro
		     MOVE cod-cli OF registro TO cliente
		     DISPLAY cliente 
             MOVE 'S' TO Operacion
             CALL gestor_archivo
             USING operacion, registro, fs-clientes
             DISPLAY "File Status START"
             DISPLAY fs-clientes
             PERFORM until fs-clientes = '10' or
               cod-cli OF registro not = cliente 		  
               MOVE 'N' TO Operacion
               CALL gestor_archivo 
			   USING operacion, registro, fs-clientes
			   IF cod-cli OF registro = cliente
                 DISPLAY '  Lectura:'
                 DISPLAY COD-CLI   OF registro
                 DISPLAY nro-sec   OF registro
                 DISPLAY fec-desde OF registro
                 DISPLAY fec-hasta OF registro
                 DISPLAY CATEG-HAB OF registro
                 DISPLAY importe   OF registro
                 DISPLAY '------------'
			   ELSE
			     DISPLAY "NO existe cliente."
			   END-IF			   
		     END-PERFORM	 
          END-IF
         END-PERFORM.
		 
      *		 MOVE "00000608" to cod-cli of registro
      *		 MOVE "0003" to nro-sec of registro
      *		 MOVE 'D' TO Operacion
      *		 CALL gestor_archivo
      *             USING operacion, registro, fs-clientes
      *		 DISPLAY " FS Delete: "
      *		 DISPLAY fs-clientes
      *		 MOVE "00006908" to cod-cli of registro
      *		 MOVE "0001" to nro-sec of registro
      *		 MOVE 'D' TO Operacion
      *		 CALL gestor_archivo
      *             USING operacion, registro, fs-clientes
      *		 DISPLAY " FS Delete: "
      *		 DISPLAY fs-clientes		 
		 
         MOVE 'C' TO Operacion.
         CALL gestor_archivo USING operacion, registro, fs-clientes.
         DISPLAY "File Status Close".
         DISPLAY fs-clientes.
         STOP RUN.
